﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Metro.Core;

namespace Weather
{
    public class Widget : Metro.Core.Widget
    {
        private WidgetControl _widgetControl;
        public Settings Sett;
        public static Widget Instance;
        public LocaleManager LocaleManager;

        public Widget()
        {
            Instance = this;
        }


        public override string Name
        {
            get { return "Weather"; }
        }

        public override UserControl WidgetControl
        {
            get { return _widgetControl; }
        }

        public override string IconPath
        {
            get { return null; }
        }

        public override Point Position
        {
            get { return new Point(Sett.Col, Sett.Row); }
            set
            {
                Sett.Col = (int)value.X;
                Sett.Row = (int)value.Y;
            }
        }

        public override bool HasHub
        {
            get { return false; }
        }

        public override UserControl HubControl
        {
            get { return null; }
        }

        public override void Load()
        {
            Sett = Settings.Read(E.ConfigDirectory + "\\Weather.conf");

            LocaleManager = new LocaleManager(E.Path + "\\Weather\\Localization");
            LocaleManager.LoadLocale(E.Locale);
            //ResourceManager = new HTCHome.Core.ResourceManager(E.Path + "\\WeatherClock", Sett.Skin);

            _widgetControl = new WidgetControl();
            _widgetControl.Load();
        }

        public void UpdateSettings()
        {
            //_widgetControl.UpdateSettings();
        }


        public override void Unload()
        {
            _widgetControl.Unload();
            Sett.Write(E.ConfigDirectory + "\\Weather.conf");
        }

        public void AddMenuItem(MenuItem item)
        {
            AddContextMenuItem(item);
        }

        public void SetBackground(Brush brush)
        {
            SetBgBrush(brush);
        }

        public override event AddContextMenuItemHandler AddContextMenuItem;
        public override event SetBgBrushHandler SetBgBrush;
    }
}
